<include file="Public/header"/>
<div class="park-header">
    <div class="park-header__title">登录</div>
</div>
<div class="container">
    <form class="admin-form" onsubmit="return sub_login();">
        <div class="admin-form-group">
            <label>
                <i class="iconfont icon-user"></i>
            </label>
            <input type="text" placeholder="请输入你的账号" name="phone" id="phone">
        </div>
        <div class="admin-form-group">
            <label>
                <i class="iconfont icon-lock"></i>
            </label>
            <input type="password" placeholder="请输入你的密码" name="password" id="password">
            <span class="password-eye">
                <i class="iconfont icon-biyan"></i>
                <i class="iconfont icon-eye" style="display: none;"></i>
            </span>
        </div>
        <p class="admin-forget">
            <a>忘记密码</a>
        </p>
        <button type="submit" class="admin-form-btn">登录</button>
    </form>
</div>
<script src="__ROOT__/Public/Home/layer/layer.js"></script>
<script>
    $(function () {
        $(document).on('click', '.password-eye', function () {
            $(this).children().toggle();
            var input = $(this).parent().find('input');

            if (input.attr('type') === 'text') {
                input.attr('type', 'password');
            }else if (input.attr('type') === 'password') {
                input.attr('type', 'text')
            }
        });
    });
    function sub_login(){
        var phone = $('#phone').val();
        if(!phone){
            layer.open({
                content:'请输入你的账号'
                ,skin: 'msg'
                ,time: 2 //2秒后自动关闭
            });
            return false;
        }
        var password = $('#password').val();
        if(!password){
            layer.open({
                content:'请输入你的密码'
                ,skin: 'msg'
                ,time: 2 //2秒后自动关闭
            });
            return false;
        }
        $.post('/Business/Index/login/',{phone:phone,password:password},function(data){
            layer.open({
                content:data.msg
                ,skin: 'msg'
                ,time: 2 //2秒后自动关闭
            });
            if(data.code==200){
                window.location = '/Business/User/index/';
            }
        },'json');
        return false;
    }
</script>
</body>
</html>